<template>
	<view class="f26r col363636">
		<scroll-view scroll-x="true" class="whSpaNow backColWhite lh90r f28r teAliCenter">
			<view :class="['wPer50', 'disInBlo', 'poRel',
					nowCurrent == 0 ? 'foWeiBold col64aeb4' : ''
				]" @click="cliTopBtn(0)"
			>
				充值金额
				<text class="w50r h4r backCol64aeb4 poAbs bom0 left50P trTrXn50P"
					v-show="nowCurrent == 0"
				></text>
			</view>
			<view :class="['wPer50', 'disInBlo', 'poRel',
					nowCurrent == 1 ? 'foWeiBold col64aeb4' : ''
				]" @click="cliTopBtn(1)"
			>
				充值介绍
				<text class="w50r h4r backCol64aeb4 poAbs bom0 left50P trTrXn50P"
					v-show="nowCurrent == 1"
				></text>
			</view>
		</scroll-view>
		<swiper @change="swiperChaFun" :current="nowCurrent" class="minH100vC90r">
			<swiper-item class="overYS p20r boSiBorBox">
				<view class="h70r mb20r lh70r colFff teAliCenter">
					<view class="w200r backCol67c23a borRad35r floLeft"
						@click="cliAddBtn(1)"
					>
						新增充值金额
					</view>
					<view class="w200r backColF59a23 borRad35r floRight"
						@click="goUrl('/pages/index/rechargeList')"
					>
						用户充值明细
					</view>
				</view>
				<view class="p20r backColWhite borRad10r mb20r boxSha0a5a12a0Rgb217a226a223a50Per"
					v-for="item in tempList0" :key="item.id"
				>
					<view class="disFlex">
						<view class="flex1">
							<text class="col999">
								充值id：
							</text>
							{{item.id}}
						</view>
						<!-- <view class="flex1 teAliRight">
							<text class="col999">
								茶室id：
							</text>
							{{item.tid}}
						</view> -->
					</view>
					<view class="disFlex mt20r colFf3627">
						<view class="flex1">
							<text class="col999">
								充值金额：
							</text>
							{{item.balance}}
						</view>
						<view class="flex1 teAliRight">
							<text class="col999">
								赠送金额：
							</text>
							{{item.giftAmount}}
						</view>
					</view>
					<view class="disFlex mt20r">
						<view :class="['flex1', item.type == 1 ? 'col67c23a' : 'colBd2125']">
							<text class="col999">
								启用/禁用：
							</text>
							{{
								item.type == 1 ? '启用' :
								item.type == 2 ? '禁用' : item.type
							}}
						</view>
						<view class="flex1 teAliRight">
							<view class="disInBlo w120r lh40r borRad20r teAliCenter colFff backCol31a0ff"
								@click="cliModifyBtn(item)"
							>
								修改
							</view>
						</view>
					</view>
				</view>
				<view class="f28r col999 teAliCenter poAbs top50P left50P trTrXn50P" v-if="tempList0.length == 0">
					暂无充值金额
				</view>
			</swiper-item>
			<swiper-item class="overYS p20r boSiBorBox">
				<view class="w200r backCol67c23a lh70r borRad35r mb20r colFff teAliCenter"
					@click="cliAddBtn(2)"
				>
					新增充值介绍
				</view>
				<view class="p20r backColWhite borRad10r mb20r boxSha0a5a12a0Rgb217a226a223a50Per"
					v-for="item in tempList1" :key="item.id"
				>
					<view class="disFlex">
						<view class="flex1">
							<text class="col999 w150r disInBlo">
								充值id：
							</text>
							{{item.id}}
						</view>
						<!-- <view class="flex1 teAliRight">
							<text class="col999">
								茶室id：
							</text>
							{{item.tid}}
						</view> -->
					</view>
					<view class="disFlex mt20r">
						<view class="w150r col999">
							充值介绍：
						</view>
						<view class="flex1">
							{{item.introduce}}
						</view>
					</view>
					<view class="disFlex mt20r">
						<view :class="['flex1', item.type == 1 ? 'col67c23a' : 'colBd2125']">
							<text class="col999 w150r">
								启用/禁用：
							</text>
							{{
								item.type == 1 ? '启用' :
								item.type == 2 ? '禁用' : item.type
							}}
						</view>
						<view class="flex1 teAliRight">
							<view class="disInBlo w120r lh40r borRad20r teAliCenter colFff backCol31a0ff"
								@click="cliModifyBtn(item)"
							>
								修改
							</view>
						</view>
					</view>
				</view>
				<view class="f28r col999 teAliCenter poAbs top50P left50P trTrXn50P" v-if="tempList1.length == 0">
					暂无充值介绍
				</view>
			</swiper-item>
		</swiper>
	</view>
</template>
<script>
import { inquiryToLogin } from '@/utils/utils.js'
import { getRechargeList } from '@/utils/api.js'
export default {
	data() {
		return {
			token: '',
			nowCurrent: 0,
			tempList0: [],
			tempList1: [],
		}
	},
	onLoad() {
		
	},
	onShow() {
		inquiryToLogin().then(res => {
			this.token = res;
			this.getDataList1();
		});
	},
	methods: {
		getDataList1() {
			this.tempList0 = [];
			this.tempList1 = [];
			getRechargeList({token: this.token}).then(res => {
				if(res.message && res.message.length) {
					res.message.forEach((item1, index) => {
						console.log(item1)
						if(item1.status == 1) {
							this.tempList0.push(item1)
							this.tempList0.forEach(item2 => {
								item2.giftAmount = Math.round((Number(item2.reality_balance) - Number(item2.balance)) * 100) / 100;
							})
							
						}else if(item1.status == 2) {
							this.tempList1.push(item1)
						}
					})
					// console.log('tempList0', this.tempList0)
					// console.log('tempList1', this.tempList1)
				}
			})
		},
		cliTopBtn(type) {
			if(this.nowCurrent != type) {
				this.nowCurrent = type;
			}
		},
		swiperChaFun(eee) {
			if (eee.detail.source == 'touch') {
				this.nowCurrent = eee.detail.current;
			}
		},
		cliAddBtn(status) {
			uni.navigateTo({
				url: '/pages/index/addRechargeDetail?type=1&status=' + status
			})
		},
		cliModifyBtn(item) {
			console.log(item)
			uni.navigateTo({
				url: '/pages/index/addRechargeDetail?type=2&status=' + item.status + '&item=' + JSON.stringify(item)
			})
		},
		goUrl(url) {
			uni.navigateTo({ url })
		}
	}
}
</script>
<style>
</style>